home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
pcr
/
pcr4_4.lha
/
DIST
/
debugnub
/
CirioNubProcs0.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-16
|
5KB
|
217 lines
/* begincopyright
Copyright (c) 1988-1991 Xerox Corporation. All rights reserved.
Use and copying of this software and preparation of derivative works based
upon this software are permitted. Any distribution of this software or
derivative works must comply with all applicable United States export
control laws. This software is made available AS IS, and Xerox Corporation
makes no warranty about the software, its performance or its conformity to
any specification. Any person obtaining a copy of this software is requested
to send their name and post office or electronic mail address to:
PCR Coordinator
Xerox PARC
3333 Coyote Hill Rd.
Palo Alto, CA 94304
endcopyright */
/*
* CirioNubProcs0.c
*
* Demers, June 15, 1991 4:57:14 pm PDT
*/
#include "xr/Errno.h"
#include "xr/ThreadsBackdoor.h"
#include "xr/CirioNubProtocol.h"
#include "xr/CirioNubMarshall.h"
#include "xr/CirioNubProcs.h"
#include "xr/CirioNubEnvironment.h"
#include "xr/ThreadsMsg.h"
extern CirioNubRetCode
CirioNubStoreBytesToVPTextSegments(/*
char *bytes,
char *addr,
int nBytes
*/);
extern int
CirioNubFetchBytesFromVPTextSegment(/*
char *bytes,
char *addr,
int nBytes,
int vpi
*/);
extern bool
CirioNubIsTextAddress(/*
char *addr
*/);
CirioNubRetCode
CirioNubServeNull(argc, args)
int argc;
unsigned *args;
{
unsigned versionRequest, versionReply;
if( argc > 1 ) return(cnrc_badArgs);
versionRequest = args[0];
if( versionRequest < CIRIO_NUB_PROCS_LOW_VERSION )
versionReply = CIRIO_NUB_PROCS_LOW_VERSION;
else if( versionRequest > CIRIO_NUB_PROCS_VERSION )
versionReply = CIRIO_NUB_PROCS_VERSION;
else
versionReply = versionRequest;
return CirioNubPutCard32(
CIRIO_NUB_VERSION(
CIRIO_NUB_PROTOCOL_VERSION,
versionReply
)
);
}
static CirioNubRetCode
CirioNubDoGet(sendProc, addr, len)
CirioNubRetCode (*sendProc)();
char *addr;
int len;
{
static /* CirioNub is single-threaded! */ long myBuf[2048];
if( CirioNubIsTextAddress(addr) ) {
if( len > sizeof(myBuf) ) len = sizeof(myBuf);
if( CirioNubFetchBytesFromVPTextSegment(myBuf, addr, len, 0) >= 0 ) {
return (*sendProc)(myBuf, len);
} else {
return (*sendProc)(NIL, 0);
}
} else if( CirioNubCanAccess(addr, len, FALSE) ) {
return (*sendProc)(addr, len);
} else {
return (*sendProc)(NIL, 0);
}
}
CirioNubRetCode
CirioNubServeGetBytes (argc, args)
int argc;
unsigned *args;
{
char *addr;
int nBytes;
if( argc != 2 ) return(cnrc_badArgs);
addr = (char *)(args[0]);
nBytes = (unsigned)(args[1]);
return CirioNubDoGet(CirioNubPutBlock8, addr, nBytes);
}
static CirioNubRetCode
CirioNubDoPut( data, addr, len )
char *data;
char *addr;
int len;
{
if( CirioNubIsTextAddress(addr) ) {
return CirioNubStoreBytesToVPTextSegments(data, addr, len);
} else if( CirioNubCanAccess(addr, len, TRUE) ) {
while( len > 0 ) { *addr++ = *data++; len -= (sizeof *addr); }
return CirioNubPutInt32(0);
} else {
return CirioNubPutInt32(-1);
}
}
CirioNubRetCode
CirioNubServePutBytes (argc, args)
int argc;
unsigned *args;
{
char *addr;
int nBytes;
char *bytes;
if( argc != 3 ) return(cnrc_badArgs);
addr = (char *)(args[0]);
nBytes = (unsigned)(args[1]);
bytes = (char *)(args[2]);
return CirioNubDoPut(((char *)(bytes)), ((char *)(addr)), nBytes );
}
CirioNubRetCode
CirioNubServeGetWords16 (argc, args)
int argc;
unsigned *args;
{
short *addr;
int nBytes;
if( argc != 2 ) return(cnrc_badArgs);
addr = (short *)(args[0] & (~01));
nBytes = (unsigned)(args[1]);
return CirioNubDoGet(CirioNubPutBlock16, addr, nBytes);
}
CirioNubRetCode
CirioNubServePutWords16 (argc, args)
int argc;
unsigned *args;
{
short *addr;
int nBytes;
short *bytes;
if( argc != 3 ) return(cnrc_badArgs);
addr = (short *)(args[0] & (~0x1));
nBytes = (unsigned)(args[1]);
bytes = (short *)(args[2] & (~0x1));
return CirioNubDoPut(((char *)(bytes)), ((char *)(addr)), nBytes );
}
CirioNubRetCode
CirioNubServeGetWords32 (argc, args)
int argc;
unsigned *args;
{
long *addr;
int nBytes;
if( argc != 2 ) return(cnrc_badArgs);
addr = (long *)(args[0] & (~0x3));
nBytes = (unsigned)(args[1]);
return CirioNubDoGet(CirioNubPutBlock32, addr, nBytes);
}
CirioNubRetCode
CirioNubServePutWords32 (argc, args)
int argc;
unsigned *args;
{
long *addr;
int nBytes;
long *bytes;
if( argc != 3 ) return(cnrc_badArgs);
addr = (long *)(args[0] & (~0x3));
nBytes = (unsigned)(args[1]);
bytes = (long *)(args[2] & (~0x3));
return CirioNubDoPut(((char *)(bytes)), ((char *)(addr)), nBytes );
}